import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import {userType} from "./util/base";
import Cookies from 'js-cookie'
import 'default-passive-events'

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')

let token = Cookies.get("token")
console.log('main-token',token);
if(token){
  let {user_type} = userType(token);
  let {user_name} = userType(token);
  store.commit('setUserType',user_type)
  store.commit('setUserName',user_name)
  store.commit('setToken',token)
  console.log('main-user_type',user_type);
  console.log('vuexToken',store.state.token);
  // if(window.location.href.includes('callback')){
  //
  // }else{
  //   if (user_type == 1){
  //     router.push('/user')
  //   }else if(user_type == 2){
  //     router.push('/org')
  //   }else if(user_type == 3){
  //     router.push('/admin')
  //   }
  // }
}

Vue.config.productionTip = false
Vue.use(ElementUI);
